package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController()
@RequestMapping("/setmeal")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    /**
     * 查询套餐列表
     * @return
     */
    @PostMapping("/getSetmeal")
    public Result getSetmeal(){
        List<Setmeal> setmealList = setmealService.getSetmeal();

        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS, setmealList);
    }

    /**
     * 根据套餐id查询套餐
     * @param id
     * @return
     */
    @PostMapping("/findById")
    public Result findById(Integer id){
        Setmeal setmeal = setmealService.findById(id);

        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS, setmeal);
    }
}
